package com.choudou5.solr.bean;

import cn.hutool.core.map.MapUtil;
import com.choudou5.solr.util.ArrayUtil;
import org.apache.commons.collections.MapUtils;
import org.apache.solr.common.SolrDocumentList;

import java.util.*;

/**
 * @name：SolrQueryResp 说明
 * @author：xuhaowen
 * @date：2018-08-25
 */
public class SolrQueryResp extends SolrDocumentList {


    private int qt; //查询时间(毫秒)

    public SolrQueryResp() {
    }

    public SolrQueryResp(SolrDocumentList list, int qt) {
        setStart(list.getStart());
        setMaxScore(list.getMaxScore());
        setNumFound(list.getNumFound());
        addAll(list);
        setQt(qt);
    }

    private Map<String, List<String>> facetDataListMap; // 格式：{filed:date=值, field:date2=值}

    public int getQt() {
        return qt;
    }
    public void setQt(int qt) {
        this.qt = qt;
    }

    public Map<String, List<String>> getFacetDataListMap() {
        return facetDataListMap==null? MapUtils.EMPTY_MAP:facetDataListMap;
    }

    public void setFacetDataListMap(Map<String, List<String>> facetDataListMap) {
        this.facetDataListMap = facetDataListMap;
    }

    public void addFacetDataData(String field, List<String> facetDataData) {
        if(this.facetDataListMap == null)
            this.facetDataListMap = new HashMap<>(5);
        this.facetDataListMap.put(field, facetDataData);
    }
}
